#if !defined(__DAEMON_SUB_PROCESS_H)
#define __DAEMON_SUB_PROCESS_H
#include "app_pool.h"
#include "app_mqtt.h"
#include "app_device.h"
#include "app_bt.h"
#include "log/log.h"
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/reboot.h>
#include <stdlib.h>

// #define EXE_PATH "/usr/bin/gateway" // 开发板
#define EXE_PATH ""                 // 测试
#define MAX_FAIL_COUNT 10           // 子进程最大失败次数
typedef struct
{
    pid_t pid;       // 子进程pid
    int fail_count;  // 子进程失败次数
    char *cmd_param; // 子进程启动参数
} SubProcess_t;

// 初始化子进程
SubProcess_t *deamon_sub_process_init(char *cmd_param);
// 检查并启动子进程
int deamon_sub_process_checkStart(SubProcess_t *sub_process);
// 关闭子进程
void deamon_sub_process_close(SubProcess_t *sub_process);

#endif // __DAEMON_SUB_PROCESS_H
